/**
 * 项目对应的service
 */
define(function (require) {
    'use strict';
    var angular = require('angular');
    
    angular.module('projectServiceApp',[])
        .factory('projectService',['$http',function($http){
            function httpGet(url,data){
                url = '/api/index.php?r=' + url ;
                return $http.get(url,{params:data});
            }
            return {
                getProjectList :function(){
                    var url = 'ydxs/project/list/';
                    var data = {};
                    data.flag = 0;
                    data.jointparent = 1;
                    return httpGet(url,data).then(function(res){
                        var data = res.data.data;
                        return {
                            projectId:'',
                            projectList:data
                        }
                        //var projectId = '';
                        //var projectList = [];
                        //if (!data.citys) {
                            //return;
                        //}

                        //for (var i = 0; i < data.citys.length; i++) {
                            //projectList = projectList.concat(data.citys[i].list);
                        //}
                        //if (projectList.length) {
                            //projectId = projectList[0].p_projectId;
                        //}
                        //return {
                            //projectId : projectId,
                            //projectList : projectList
                        //};
                    });
                }
            };
        }]);
});
